/**
 * Created by nolan on 15/11/25.
 */
angular.module('sbAdminApp')
    .service('interfaceService', function (httpResource) {
        /**
         *
         * @param groupid
         * @param pageno
         * @param itempersize
         * @returns {*}
         */
        this.pageQuery = function (groupid, pageno, itempersize) {
            return httpResource.post('/inter/query', {'groupid': groupid, 'pageNo': pageno, 'pageSize': itempersize});
        }

        /*this.updateThreshold = function(thresholdId,threshold,avgElapsed,isElapsed,intervalTime) {
            //var data1 ="id="+thresholdId+"&threshold="+threshold+"&avgElapsed="+avgElapsed+"&isElapsed="+isElapsed+"&intervalTime="+intervalTime;
            return $http({
                method: 'POST',
                url: '/warnthreshold/updatethreshold',
                params:{"id":thresholdId,"threshold":threshold,"avgElapsed":avgElapsed,"isElapsed":isElapsed,"intervalTime":intervalTime}
            });
        }
        this.updateiswarn = function(id,value) {
            return $http({
                method: 'POST',
                url: '/warnthreshold/updateiswarn',
                params:{"id":id,"isWarn":value}
            });
        }*/
        /**
         *
         * @param id
         * @returns {*}
         */
        this.deleteInter = function (id) {
            return httpResource.post('/inter/delete', {"id": id});
        }

        /**
         *
         * @param interfaceId
         * @param interfaceName
         * @returns {*}
         */
        this.findthreshold = function (interfaceId, interfaceName) {
            return httpResource.post('/warnthreshold/findthreshold', {
                "interfaceId": interfaceId,
                "interfaceName": interfaceName
            });
        }

        /**
         *
         * @param interfaceId
         * @param threshold
         * @param iswarn
         * @param avgElapsed
         * @param isElapsed
         * @param intervalTime
         * @returns {*}
         */
        this.saveWarnthreshold = function (interfaceId, threshold, iswarn, avgElapsed, isElapsed, intervalTime) {
            return httpResource.post('/warnthreshold/addwarnthreshold', {
                "interfaceId": interfaceId,
                "threshold": threshold,
                "iswarn": iswarn,
                "avgElapsed": avgElapsed,
                "isElapsed": isElapsed,
                "intervalTime": intervalTime
            });
        }

        /**
         *
         * @param groupid
         * @returns {*}
         */
        this.queryGroup = function (groupid,interfaceId) {
            return httpResource.post('/group/queryGroup', {"groupid": groupid,"interfaceId":interfaceId});
        }

        /**
         *
         * @param groupid
         * @param interfacename
         * @returns {*}
         */
        this.addInterface = function (groupid, interfaceId,interfacename) {
            return httpResource.post('/inter/insert', {"groupid": groupid, "id":interfaceId,"interfacename": interfacename});
        }
        /**
         * 查询用户组树形结构
         */
        this.treeQuery = function () {
            return httpResource.get('/group/tree');
        };


    });
